﻿using MediatR;
using System.Numerics;
using SystemHYS.API.Application.command.RawmaterialtestingCommand;
using SystemHYS.Domian;
using SystemHYS.Infrstructre.Interface;
namespace SystemHYS.API.Application.commandler.RawmaterialtestingCommandler
{
    public class RawmaterialtestingUpdateCommandler:IRequestHandler<RawmaterialtestingUpdateCommand,int>
    {
        IRawmaterialtestingRepository rawmaterialtestingRepository;
        public RawmaterialtestingUpdateCommandler(IRawmaterialtestingRepository rawmaterialtestingRepository)
        {
            this.rawmaterialtestingRepository = rawmaterialtestingRepository;
        }

        public async Task<int> Handle(RawmaterialtestingUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = new Rawmaterialtesting
            {
                RawMaterialtestingId = request.RawMaterialtestingId,
                qualityNumber = request.qualityNumber,
                qualityName = request.qualityName,
                qualityDate = request.qualityDate.Value.ToUniversalTime(),
                qualityPerson = request.qualityPerson,
                vendor = request.vendor,
                ingredientNumber = request.ingredientNumber,
                ingredientName = request.ingredientName,
                unit = request.unit,
                specification = request.specification,
                rawMaterialBatchNumber = request.rawMaterialBatchNumber,
                size = request.size,
                typeOfQC=request.typeOfQC,
                gualitySchemeName = request.gualitySchemeName,
                state = request.state,
            };
            return await rawmaterialtestingRepository.UpdateAsyn(list);
        }
    }
}
